#include "settingwithxml.h"
#include "setting.h"

Setting::Setting() :
    m_impl(0)
{

}

Setting::~Setting()
{
    if(m_impl){
        m_impl->release();
        m_impl = 0;
    }
}

bool Setting::init(const std::string &sf)
{
    if(m_impl){
        LOG_ERROR() << "Reinit.";
        return boost::system::errc::file_exists;
    }

    m_impl = new SettingWithXML();

    if(!m_impl){
        LOG_ERROR() << strerror(boost::system::errc::not_enough_memory);
        return boost::system::errc::not_enough_memory;
    }

    if(m_impl->init(sf)){
        return true;
    }

    m_impl->release();
    m_impl = 0;

    return false;
}

